#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	char a[100][19];
	int s = 0;
	for (int i = 0; i < n; i++)
	{
		scanf("%s", a[i]);
		int sum = 0;
		for (int j = 0; j < 17; j++)
		{
			int t = a[i][j] - '0';
			switch (j)
			{
			case 0:sum += t * 7; break;
			case 1:sum += t * 9; break;
			case 2:sum += t * 10; break;
			case 3:sum += t * 5; break;
			case 4:sum += t * 8; break;
			case 5:sum += t * 4; break;
			case 6:sum += t * 2; break;
			case 7:sum += t * 1; break;
			case 8:sum += t * 6; break;
			case 9:sum += t * 3; break;
			case 10:sum += t * 7; break;
			case 11:sum += t * 9; break;
			case 12:sum += t * 10; break;
			case 13:sum += t * 5; break;
			case 14:sum += t * 8; break;
			case 15:sum += t * 4; break;
			case 16:sum += t * 2; break;
			}
		}
		int z = sum % 11;
		switch (z)
		{
		case 0: {if (a[i][17] != '1')
		{
			printf("%s\n", a[i]); s++;
		}
			  break; }
		case 1: {if (a[i][17] != '0')
		{
			printf("%s\n", a[i]); s++;
		}
			  break; }
		case 2: {if (a[i][17] != 'X')
		{
			printf("%s\n", a[i]); s++;
		}
			  break; }
		case 3: {if (a[i][17] != '9')
		{
			printf("%s\n", a[i]); s++;
		}
			  break; }
		case 4: {if (a[i][17] != '8')
		{
			printf("%s\n", a[i]); s++;
		}break; }
		case 5: {if (a[i][17] != '7')
		{
			printf("%s\n", a[i]); s++;
		}break; }
		case 6: {if (a[i][17] != '6')
		{
			printf("%s\n", a[i]); s++;
		}break; }
		case 7: {if (a[i][17] != '5')
		{
			printf("%s\n", a[i]); s++;
		}break; }
		case 8: {if (a[i][17] != '4')
		{
			printf("%s\n", a[i]); s++;
		}break; }
		case 9: {if (a[i][17] != '3')
		{
			printf("%s\n", a[i]); s++;
		}break; }
		case 10: {if (a[i][17] != '2')
		{
			printf("%s\n", a[i]); s++;
		}
			   break; }
		}
	}
	if (s == 0)
		cout << "All passed" << endl;
	return 0;
}